export default {
	state:{
		// 登录状态
		loginStatus:false,
		// token
		token:null,
		// 用户信息
		userInfo:{}
	},
	mutations:{
		updateUserInfo(state,userinfo){
			state.userInfo = userinfo;
			uni.setStorageSync('userInfo',userinfo);
		},
		// 初始化登录状态
		initUser(state){
			let token = uni.getStorageSync('token');
			if (token) {
				state.token = token;
				state.loginStatus = true;
			};
		},
		// 登录
		login(state,token){
			// state.userInfo = userinfo
			state.loginStatus = true
			state.token = token
			// 持久化存储
			uni.setStorageSync('token',JSON.stringify(token))
			console.log(state.token,'-------21312')
		},
		// 退出登录
		logout(state){
			console.log(123)
			state.userInfo = {}
			state.loginStatus = false
			state.token = null
			uni.removeStorageSync('token')
		}
	}
}